package md.mru.frontend.controllers;

import org.primefaces.event.TabChangeEvent;

import javax.faces.bean.ManagedBean;
import javax.faces.bean.ManagedProperty;
import javax.faces.bean.ViewScoped;
import java.io.Serializable;

/**
 * @author sergiu.marin
 * @since 29.03.2014
 */
@ManagedBean
@ViewScoped
public class FolderContentAdministrationBean implements Serializable {

    private static final long serialVersionUID = -4043859442747880010L;

    @ManagedProperty(value = "#{folderAdministrationBean}")
    private FolderAdministrationBean folderAdministrationBean;
    @ManagedProperty(value = "#{employmentDataBean}")
    private EmploymentDataAdministrationBean employmentDataAdministrationBean;
    @ManagedProperty(value = "#{skillsDataBean}")
    private SkillsDataAdministrationBean skillsDataAdministrationBean;
    @ManagedProperty(value = "#{additionalDataBean}")
    private AdditionalDataAdministrationBean additionalDataAdministrationBean;

    public void onTabChange(TabChangeEvent event) {
        switch (event.getTab().getId()) {
            case "folder_details_orders_tab":
                folderAdministrationBean.initFolderOrdersTab();
                break;
            case "folder_details_employment_data_tab":
                employmentDataAdministrationBean.initEmploymentDataTab();
                break;
            case "folder_details_skills_data_tab":
                skillsDataAdministrationBean.initSkillsDataTab();
                break;
            case "folder_details_additional_data_tab":
                additionalDataAdministrationBean.initAdditionalDataTab();
            case "folder_details_confidential_data_tab":
                // TODO: add functionality
        }
    }

    public void setFolderAdministrationBean(FolderAdministrationBean folderAdministrationBean) {
        this.folderAdministrationBean = folderAdministrationBean;
    }

    public void setEmploymentDataAdministrationBean(EmploymentDataAdministrationBean employmentDataAdministrationBean) {
        this.employmentDataAdministrationBean = employmentDataAdministrationBean;
    }

    public void setSkillsDataAdministrationBean(SkillsDataAdministrationBean skillsDataAdministrationBean) {
        this.skillsDataAdministrationBean = skillsDataAdministrationBean;
    }

    public void setAdditionalDataAdministrationBean(AdditionalDataAdministrationBean additionalDataAdministrationBean) {
        this.additionalDataAdministrationBean = additionalDataAdministrationBean;
    }
}
